﻿@{
    ViewBag.Title = "Control Panel";
}
<script src="/Scripts/MiscCommands.js"></script>

<br />
<br />
<h3><i>Approval Control Panel</i></h3>
<table>
    <thead>
        <tr>
            <td>Request No.</td>
            <td>Request Type</td>

            <td>Associated Project</td>
            <td>User Requesting</td>
            <td>Approved?</td>
            <td>Actioned?</td>
            <td>Date Created</td>
            <td>Date Approved</td>
            <td>Date Actioned</td>
            <td>Approve Request</td>
            <td>Comments</td>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in ViewBag.ListOfReqs)
        {
            <tr>
                <td>@item.RequestID</td>
                <td>@item.tblRequestType.strRequestName</td>

                <td>
                    @{
            if (item.ProjectID != null)
            {
                ViewBag.AssocProj = item.Projects.strProjectName;
            }
            else
            {
                ViewBag.AssocProj = "None";
            }
                    }
                    @ViewBag.AssocProj
                </td>
                <td>@item.tblUser.strFirstName @item.tblUser.strLastName</td>
                <td>@{
            if (item.dtmApproved != null)
            {
                ViewBag.Approval = "yes";
            }
            else
            {
                ViewBag.Approval = "no";
            }
                    }@ViewBag.Approval</td>
                <td>@{
            if (item.dtmCompleted != null)
            {
                ViewBag.Actioned = "yes";
            }
            else
            {
                ViewBag.Actioned = "no";
            }
                }@ViewBag.Actioned</td>
                <td>@item.dtmCreated.ToString()</td>
                <td>@{
                    if(item.dtmApproved!=null)
                    {
                        ViewBag.dtmApproved = item.dtmApproved.ToString();
                    }else{
                        ViewBag.dtmApproved = "Not Approved";
                    }
                    }@ViewBag.dtmApproved</td>
                <td>@{
            if (item.dtmCompleted != null)
            {
                ViewBag.dtmCompleted = item.dtmCompleted.ToString();
            }
            else
            {
                ViewBag.dtmCompleted = "Not Approved";
            }
}@ViewBag.dtmCompleted</td>   
                
                <td>
                    @{
            if (item.dtmApproved == null)
            {
                //If the request hasnt been approved
                //Show a box, because this can be approved
                //Have this link and approve thre resource

                
                
                 <form action="/ControlPanel/approveStorage" method="post">
                     <input name="inputJob" value="@item.RequestID" type="hidden" />
                     <input type="submit" value="Approve" />
                 </form><br />
                 <form action="/ControlPanel/denyStorage" method="post">
                     <input name="inputJob" value="@item.RequestID" type="hidden" />
                     <input type="submit" value="Deny" />
                 </form>
                 
                 
                
            }


}
                </td>
                <td>
                    <div id="ModifyComment">
                        <form action="/ControlPanel/ModifyCommentApprover" method="post">
                            <table align="center">
                                 <tr>
                                    <td>
                                        <input name="theComment" type="text" style="width:100px" value="@item.Comments"> <input type="submit" value="Modify Comment" />
                                        <input name="theReq" type="hidden" value="@item.RequestID" />
                                     <td>
                                 </tr>
                             </table>
                         </form>
                     </div>       
                </td>
            </tr>
        }
        
    </tbody>
</table>
<div id="openMyProjs" style="text-align:left">
    <form action="/MyProjects/Index" method="post">
        <input type="submit" value="View Projects" />
    </form>
</div>